/***
RippleFilter
创建人：ZЁЯ¤　身高：168cm+；体重：57kg+；未婚（已有女友）；最爱的运动：睡觉；格言：路见不平，拔腿就跑。QQ：358315553。
创建时间：2012年12月06日 15:42:54
简要说明：这家伙很懒什么都没写。
用法举例：这家伙还是很懒什么都没写。
*/

package zero.shaders.test{
	import flash.display.*;
	import flash.geom.*;
	import flash.utils.*;
	import zero.shaders.*;
	
	/**
	 * 
	 * 水波纹
	 * 
	 */	
	public class RippleFilter extends BaseShader{
		
		public static const nameV:Vector.<String>=new <String>["alpha","center","displacement","size","ripplewidth","phase","lightdir","lightbright"];
		//RippleFilterCode//为了编译进来
		public static const byteV:Vector.<int>=new <int>[0xa5,0x01,0x00,0x00,0x00,0xa4,0x0c,0x00,0x52,0x69,0x70,0x70,0x6c,0x65,0x46,0x69,0x6c,0x74,0x65,0x72,0xa0,0x0c,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x00,0x7a,0x65,0x72,0x6f,0x2e,0x73,0x68,0x61,0x64,0x65,0x72,0x73,0x2e,0x74,0x65,0x73,0x74,0x00,0xa0,0x0c,0x76,0x65,0x6e,0x64,0x6f,0x72,0x00,0x5a,0xa7,0xa7,0xa7,0xc1,0xa1,0xe8,0x00,0xa0,0x08,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x00,0x02,0x00,0xa0,0x0c,0x64,0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x00,0xcb,0xae,0xb2,0xa8,0xce,0xc6,0x00,0xa1,0x01,0x02,0x00,0x00,0x0c,0x5f,0x4f,0x75,0x74,0x43,0x6f,0x6f,0x72,0x64,0x00,0xa1,0x01,0x01,0x00,0x00,0x02,0x61,0x6c,0x70,0x68,0x61,0x00,0xa1,0x01,0x02,0x01,0x00,0x0c,0x63,0x65,0x6e,0x74,0x65,0x72,0x00,0xa1,0x01,0x01,0x00,0x00,0x01,0x64,0x69,0x73,0x70,0x6c,0x61,0x63,0x65,0x6d,0x65,0x6e,0x74,0x00,0xa1,0x01,0x01,0x01,0x00,0x02,0x73,0x69,0x7a,0x65,0x00,0xa1,0x01,0x01,0x01,0x00,0x01,0x72,0x69,0x70,0x70,0x6c,0x65,0x77,0x69,0x64,0x74,0x68,0x00,0xa1,0x01,0x01,0x02,0x00,0x08,0x70,0x68,0x61,0x73,0x65,0x00,0xa1,0x01,0x02,0x02,0x00,0x06,0x6c,0x69,0x67,0x68,0x74,0x64,0x69,0x72,0x00,0xa1,0x01,0x01,0x02,0x00,0x01,0x6c,0x69,0x67,0x68,0x74,0x62,0x72,0x69,0x67,0x68,0x74,0x00,0xa3,0x00,0x04,0x73,0x72,0x63,0x00,0xa1,0x02,0x04,0x03,0x00,0x0f,0x64,0x73,0x74,0x00,0x32,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x2a,0x04,0x00,0x80,0x00,0x00,0x80,0x00,0x1d,0x01,0x80,0x80,0x00,0x80,0x00,0x00,0x34,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x1d,0x04,0x00,0xc1,0x00,0x00,0x10,0x00,0x1d,0x04,0x00,0x31,0x04,0x00,0x10,0x00,0x02,0x04,0x00,0x31,0x01,0x00,0x10,0x00,0x1d,0x05,0x00,0xc1,0x04,0x00,0xb0,0x00,0x24,0x04,0x00,0x21,0x05,0x00,0x10,0x00,0x1d,0x04,0x00,0x10,0x04,0x00,0x80,0x00,0x2a,0x04,0x00,0x10,0x01,0x00,0x80,0x00,0x1d,0x01,0x80,0x40,0x00,0x80,0x00,0x00,0x34,0x00,0x00,0x00,0x01,0x80,0x40,0x00,0x32,0x04,0x00,0x20,0x3f,0x80,0x00,0x00,0x04,0x05,0x00,0x20,0x01,0x00,0x80,0x00,0x03,0x05,0x00,0x20,0x04,0x00,0xc0,0x00,0x1d,0x05,0x00,0x10,0x04,0x00,0x80,0x00,0x02,0x05,0x00,0x10,0x05,0x00,0x80,0x00,0x1d,0x04,0x00,0x20,0x05,0x00,0xc0,0x00,0x03,0x04,0x00,0x20,0x00,0x00,0xc0,0x00,0x32,0x05,0x00,0x20,0x00,0x00,0x00,0x00,0x02,0x05,0x00,0x20,0x02,0x00,0x00,0x00,0x32,0x05,0x00,0x10,0x40,0xc8,0xf5,0xc3,0x04,0x06,0x00,0x80,0x05,0x00,0xc0,0x00,0x03,0x06,0x00,0x80,0x01,0x00,0xc0,0x00,0x04,0x05,0x00,0x10,0x06,0x00,0x00,0x00,0x03,0x05,0x00,0x10,0x04,0x00,0xc0,0x00,0x1d,0x06,0x00,0x80,0x05,0x00,0x80,0x00,0x01,0x06,0x00,0x80,0x05,0x00,0xc0,0x00,0x0c,0x05,0x00,0x20,0x06,0x00,0x00,0x00,0x1d,0x05,0x00,0x10,0x04,0x00,0x80,0x00,0x03,0x05,0x00,0x10,0x05,0x00,0x80,0x00,0x1d,0x04,0x00,0x20,0x05,0x00,0xc0,0x00,0x1d,0x05,0x00,0x20,0x05,0x00,0x00,0x00,0x06,0x05,0x00,0x20,0x05,0x00,0x40,0x00,0x1d,0x05,0x00,0x10,0x05,0x00,0x80,0x00,0x32,0x05,0x00,0x20,0x3f,0x80,0x00,0x00,0x1d,0x06,0x00,0x80,0x02,0x00,0xc0,0x00,0x03,0x06,0x00,0x80,0x04,0x00,0x80,0x00,0x04,0x06,0x00,0x40,0x00,0x00,0xc0,0x00,0x03,0x06,0x00,0x40,0x06,0x00,0x00,0x00,0x1d,0x06,0x00,0x80,0x05,0x00,0x00,0x00,0x03,0x06,0x00,0x80,0x02,0x00,0x40,0x00,0x04,0x06,0x00,0x20,0x04,0x00,0xc0,0x00,0x03,0x06,0x00,0x20,0x06,0x00,0x00,0x00,0x1d,0x06,0x00,0x80,0x05,0x00,0x40,0x00,0x03,0x06,0x00,0x80,0x02,0x00,0x80,0x00,0x04,0x06,0x00,0x10,0x04,0x00,0xc0,0x00,0x03,0x06,0x00,0x10,0x06,0x00,0x00,0x00,0x1d,0x06,0x00,0x80,0x06,0x00,0x80,0x00,0x01,0x06,0x00,0x80,0x06,0x00,0xc0,0x00,0x1d,0x06,0x00,0x20,0x06,0x00,0x40,0x00,0x03,0x06,0x00,0x20,0x06,0x00,0x00,0x00,0x1d,0x06,0x00,0x80,0x05,0x00,0x80,0x00,0x01,0x06,0x00,0x80,0x06,0x00,0x80,0x00,0x1d,0x05,0x00,0x20,0x06,0x00,0x00,0x00,0x0c,0x06,0x00,0x20,0x05,0x00,0xc0,0x00,0x1d,0x06,0x00,0x10,0x04,0x00,0x80,0x00,0x03,0x06,0x00,0x10,0x06,0x00,0x80,0x00,0x1d,0x06,0x00,0x20,0x04,0x00,0x00,0x00,0x01,0x06,0x00,0x20,0x06,0x00,0xc0,0x00,0x1d,0x06,0x00,0x80,0x06,0x00,0x80,0x00,0x0d,0x06,0x00,0x20,0x05,0x00,0xc0,0x00,0x1d,0x06,0x00,0x10,0x04,0x00,0x80,0x00,0x03,0x06,0x00,0x10,0x06,0x00,0x80,0x00,0x1d,0x06,0x00,0x20,0x04,0x00,0x40,0x00,0x01,0x06,0x00,0x20,0x06,0x00,0xc0,0x00,0x1d,0x06,0x00,0x40,0x06,0x00,0x80,0x00,0x30,0x07,0x00,0xf1,0x06,0x00,0x10,0x00,0x1d,0x06,0x00,0xf3,0x07,0x00,0x1b,0x00,0x03,0x06,0x00,0xf3,0x05,0x00,0xaa,0x00,0x1d,0x03,0x00,0xf3,0x06,0x00,0x1b,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x00,0xf1,0x04,0x00,0x10,0x00,0x1d,0x03,0x00,0xf3,0x06,0x00,0x1b,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x10,0x00,0x00,0x80,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x03,0x00,0x80,0x00,0x00,0x00,0x00,0x32,0x03,0x00,0x40,0x00,0x00,0x00,0x00,0x32,0x03,0x00,0x20,0x00,0x00,0x00,0x00,0x32,0x03,0x00,0x10,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00];
		
		/**
		 * 
		 * 透明度 （0~1） 默认 1
		 * 
		 */
		public var alpha:Number;
		
		/**
		 * 
		 * 坐标 默认 null
		 * 
		 */
		public var center:Float2;
		
		/**
		 * 
		 * Displacement in pixels （0~40） 默认 18
		 * 
		 */
		public var displacement:Number;
		
		/**
		 * 
		 * Size of effect in pixels （0~ 8192） 默认 550
		 * 
		 */
		public var size:Number;
		
		/**
		 * 
		 * Size of single ripple in pixels （0~512） 默认 32
		 * 
		 */
		public var ripplewidth:Number;
		
		/**
		 * 
		 * Phase shift of ripple (change to animate) （-10~10） 默认 0
		 * 
		 */
		public var phase:Number;
		
		/**
		 * 
		 * Light direction vector (must be normalised!) 默认 null
		 * 
		 */
		public var lightdir:Float2;
		
		/**
		 * 
		 * Brightness of directional light source （0~1） 默认 0
		 * 
		 */
		public var lightbright:Number;
		

		/**
		 * 
		 * 透明度 （0~1） 默认 1<br/>
		 * 坐标 默认 null<br/>
		 * Displacement in pixels （0~40） 默认 18<br/>
		 * Size of effect in pixels （0~ 8192） 默认 550<br/>
		 * Size of single ripple in pixels （0~512） 默认 32<br/>
		 * Phase shift of ripple (change to animate) （-10~10） 默认 0<br/>
		 * Light direction vector (must be normalised!) 默认 null<br/>
		 * Brightness of directional light source （0~1） 默认 0<br/>
		 * 
		 */
		public function RippleFilter(_alpha:Number=1,_center:Float2=null,_displacement:Number=18,_size:Number=550,_ripplewidth:Number=32,_phase:Number=0,_lightdir:Float2=null,_lightbright:Number=0){
			alpha=_alpha;
			(data.alpha as ShaderParameter).value=[];
			center=_center;
			(data.center as ShaderParameter).value=[];
			displacement=_displacement;
			(data.displacement as ShaderParameter).value=[];
			size=_size;
			(data.size as ShaderParameter).value=[];
			ripplewidth=_ripplewidth;
			(data.ripplewidth as ShaderParameter).value=[];
			phase=_phase;
			(data.phase as ShaderParameter).value=[];
			lightdir=_lightdir;
			(data.lightdir as ShaderParameter).value=[];
			lightbright=_lightbright;
			(data.lightbright as ShaderParameter).value=[];
		}
		
		override public function updateParams():void{
			(data.alpha as ShaderParameter).value[0]=alpha;
			(data.center as ShaderParameter).value[0]=center.x;
			(data.center as ShaderParameter).value[1]=center.y;
			(data.displacement as ShaderParameter).value[0]=displacement;
			(data.size as ShaderParameter).value[0]=size;
			(data.ripplewidth as ShaderParameter).value[0]=ripplewidth;
			(data.phase as ShaderParameter).value[0]=phase;
			(data.lightdir as ShaderParameter).value[0]=lightdir.x;
			(data.lightdir as ShaderParameter).value[1]=lightdir.y;
			(data.lightbright as ShaderParameter).value[0]=lightbright;
		}
		

	}
}